package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ruoyi.system.entity.Facility;
import com.ruoyi.system.mapper.FacilityMapper;
import com.ruoyi.system.service.FacilityService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ruochen
 * @description 针对表【facility】的数据库操作Service实现
 * @createDate 2023-12-19 21:35:33
 */
@Service
public class FacilityServiceImpl extends ServiceImpl<FacilityMapper, Facility>
        implements FacilityService {

    @Override
    public List<Facility> getFacilityList(Facility facility) {
        LambdaQueryWrapper<Facility> facilityLambdaQueryWrapper = new LambdaQueryWrapper<>();
        // 按照创建时间倒序排列
        facilityLambdaQueryWrapper.orderByDesc(Facility::getCreateTime);
        if (facility.getName() != null) {
            facilityLambdaQueryWrapper.like(Facility::getName, facility.getName());
        }
        if (facility.getType() != null) {
            facilityLambdaQueryWrapper.like(Facility::getType, facility.getType());
        }

        return this.list(facilityLambdaQueryWrapper);
    }
}




